package com.ruoyi.project.system.mapper;

import java.util.List;
import java.util.Map;

import com.ruoyi.project.system.domain.KnowledgeCatalog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 安全常识目录Mapper接口
 * 
 * @author ruoyi
 * @date 2020-10-07
 */
@Mapper
public interface KnowledgeCatalogMapper 
{
    /**
     * 查询安全常识目录
     * 
     * @param id 安全常识目录ID
     * @return 安全常识目录
     */
    public KnowledgeCatalog selectKnowledgeCatalogById(Integer id);

    /**
     * 查询安全常识目录列表
     * 
     * @param knowledgeCatalog 安全常识目录
     * @return 安全常识目录集合
     */
    public List<KnowledgeCatalog> selectKnowledgeCatalogList(KnowledgeCatalog knowledgeCatalog);

    /**
     * 新增安全常识目录
     * 
     * @param knowledgeCatalog 安全常识目录
     * @return 结果
     */
    public int insertKnowledgeCatalog(KnowledgeCatalog knowledgeCatalog);

    /**
     * 修改安全常识目录
     * 
     * @param knowledgeCatalog 安全常识目录
     * @return 结果
     */
    public int updateKnowledgeCatalog(KnowledgeCatalog knowledgeCatalog);

    /**
     * 删除安全常识目录
     * 
     * @param id 安全常识目录ID
     * @return 结果
     */
    public int deleteKnowledgeCatalogById(Integer id);

    /**
     * 批量删除安全常识目录
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteKnowledgeCatalogByIds(Integer[] ids);

    /**
     * 查询根级目录
     * @return
     */
    @Select(" select id,name,parent_id from knowledge_catalog where parent_id = 0 ORDER BY sequence ")
    List<Map<String,Object>> selectCatList();

    /**
     * 查询子级目录
     * @return
     */
    @Select(" select id,name,parent_id from knowledge_catalog where parent_id = #{parent_id} ORDER BY sequence ")
    List<Map<String,Object>> selectCatChildList( Integer parent_id);


    /**
     * 根据类别名称查询
     * @param name
     * @return
     */
    @Select("select * from knowledge_catalog where name=#{name}")
    KnowledgeCatalog selectName(@Param("name") String name);

    List<KnowledgeCatalog> selectWxKnowledgeCatalogList(KnowledgeCatalog knowledgeCatalog);
}
